sap.ui.define(
  [
    "sap/ui/core/UIComponent",
    "sap/ui/model/json/JSONModel",
    "sap/ui/model/resource/ResourceModel",
    "sap/ui/Device",
  ],
  function (UIComponent, JSONModel, ResourceModel, Device) {
    "use strict";
    return UIComponent.extend("demo.walkthrough.Component", {
      metadata: {
        interfaces: ["sap.ui.core.IAsyncContentCreation"],
        manifest: "json",
      },
      init: function () {
        UIComponent.prototype.init.apply(this, arguments);

        let oData = {
          appId: "demo.walkthrough",
          recipient: {
            name: "Xucong",
          },
        };
        let oModel = new JSONModel(oData);
        this.setModel(oModel);

        let i18nModel = new ResourceModel({
          bundleName: "demo.walkthrough.i18n.i18n",
        });
        this.setModel(i18nModel, "i18n");

        // set device model
        let oDeviceModel = new JSONModel(Device);
        oDeviceModel.setDefaultBindingMode("OneWay");
        this.setModel(oDeviceModel, "device");

        // create the views based on the url/hash
        this.getRouter().initialize();
      },

      getContentDensityClass: function () {
        if (!this._sContentDensityClass) {
          if (!Device.support.touch) {
            this._sContentDensityClass = "sapUiSizeCompact";
          } else {
            this._sContentDensityClass = "sapUiSizeCozy";
          }
        }
        return this._sContentDensityClass;
      },
    });
  }
);
